<template>
    <div>
        <table border="1" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>商品名</th>
                    <th>价格</th>
                    <th>生产日期</th>
                    <th>保质期</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr v-for="item, index in newarr" :key="index">
                    <td>{{ item.name }}</td>
                    <td>{{ item.moeny }}</td>
                    <td>{{ item.scyear }}</td>
                    <td>{{ item.bzyear }}</td>
                    <td>
                        <button>编辑</button>&nbsp;&nbsp;
                        <button>删除</button>
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="box-1">
            <getdang></getdang>
        </div>
    </div>
</template>

<script>
import bus from "../JS/bus";
export default {
    data() {
        return {
            arr: [
                { name: '奥利奥', moeny: 10, scyear: 2021 - 3 - 12, bzyear: '6个月' },
                { name: '奥利奥', moeny: 10, scyear: 2021 - 3 - 12, bzyear: '6个月' },
                { name: '奥利奥', moeny: 10, scyear: 2021 - 3 - 12, bzyear: '6个月' },
                { name: '奥利奥', moeny: 10, scyear: 2021 - 3 - 12, bzyear: '6个月' },
                { name: '奥利奥', moeny: 10, scyear: 2021 - 3 - 12, bzyear: '6个月' },
                { name: '奥利奥', moeny: 10, scyear: 2021 - 3 - 12, bzyear: '6个月' },
                { name: '奥利奥', moeny: 10, scyear: 2021 - 3 - 12, bzyear: '6个月' },
                { name: '奥利奥', moeny: 10, scyear: 2021 - 3 - 12, bzyear: '6个月' },
                { name: '奥利奥', moeny: 10, scyear: 2021 - 3 - 12, bzyear: '6个月' },
                { name: '奥利奥', moeny: 10, scyear: 2021 - 3 - 12, bzyear: '6个月' }
            ],
            newarr:[],
            pageSize:6
        }
    },
    mounted() {
        this.newarr=this.arr.slice(0,this.pageSize)
        bus.$emit("send", this.arr);
        bus.$emit("send2", this.pageSize);
        bus.$on("send1", (val) => {
            // console.log(val);
            this.newarr = val;
        });
    }
}
</script>

<style lang="less" scoped>
td {
    text-align: center;
}
.box-1 {
    position: absolute;
    top: 465px;
    left: 650px;
}
</style>